package com.baosight.sczx.zm.cf.service;

import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.threadlocal.UserSession;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.common.zm.cInterface.Department;
import com.baosight.sczx.common.zm.cInterface.cs.InitialData;
import com.baosight.sczx.zm.cf.domain.ZMCFPenalty;

public class ServiceZMCF20 extends ServiceEPBase {

	/**
	 * 初始化方法
	 * <p>Function: initLoad</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCF15</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-7-8上午05:14:44 严洪浩
	 * </p>
	 *
	 */
	@Override
	public EiInfo initLoad(EiInfo inInfo) {
		inInfo.addBlock(EiConstant.resultBlock).set("showCount", "true");//如果不加这个，翻页的统计和显示是错误的
		
		EiInfo outInfo = this.query(inInfo);
		outInfo.addBlock(Department.getInstance().getConstructionUnit(false));
		outInfo.addBlock(InitialData.getInstance().getEiBlockByNo("cmes.cl.penaltyType"));
		outInfo.addBlock(InitialData.getInstance().getEiBlockByNo("cmes.cl.penaltyType", "cmes.cl.penaltyTypes", true));
		
		String fdSendnoteDepartmentId = outInfo.getBlock("result").getCellStr(0, "fdSendnoteDepartmentId");//开单部门ID
		String fdSendnoteDepartment = Department.getInstance().getDepartmentNameById(fdSendnoteDepartmentId);//开单部门
		outInfo.set("fdSendnoteDepartment", fdSendnoteDepartment);
		outInfo.set("fdSendnoteDepartmentId", fdSendnoteDepartmentId);
		
		return outInfo;
	}

	/**
	 * 查询方法
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCF15</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-7-8上午05:14:50 严洪浩
	 * </p>
	 *
	 */
	@Override
	public EiInfo query(EiInfo inInfo) {
		String fdDepartmentId = UserSession.getInSessionProperty("orgCode") == null ? "" : UserSession.getInSessionProperty("orgCode").toString();//登陆人所在部门
		StaticTools.setQueryParameters(inInfo, "fdDepartmentId", fdDepartmentId, true);//添加查询条件 责任单位 为 登陆人所在单位
		StaticTools.setQueryParameters(inInfo, "fdStatus", "生效", true);//只能看到生效的单子
		
		EiInfo outInfo = super.query(inInfo, "ZMCFPenalty.query", new ZMCFPenalty());
		return outInfo;
	}
}
